<extend name="Extends/base" />
<block name="title">徒弟列表</block>
<block name="css">
</block>
<block name="body_style">class="bgc-f2f4f6"</block>
<block name="body">
    <div class="pt30 plr20">
        <div class="form-layout form-inline">
            <form id='myForm'>
                <div class="control-group">
                    <label class="control-label"><sub class="control-sub"></sub> 徒弟类型：</label>
                    <div class="control-form">
                        <div class="cus-sel cus-sel-h33" data-toggle="formSelect">
                            <div class="cus-sel-chosed">
                                <input type="text" name="type" value="1" style="display:none;">
                                <span class="cus-sel-chosed-txt" data-value="">裂变徒弟</span>
                                <span class="jselect-icon"></span>
                            </div>
                            <div class="cus-sel-list" style="display: none;">
                                <ul>
                                    <li><a href="javascript:;" data-value="1">裂变徒弟</a></li>
                                    <li><a href="javascript:;" data-value="2">直接徒弟</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
            <div class="control-group">
                <a href="javascript:;" class="c-btn c-btn-blue mr10 search-btn">查询</a>
            </div>
        </div>

        <div class="c-nodata pt100 c-t-center">
            <img src="__PC__/images/nodata.png">
            <p class="pt30 c-f14 msg"></p>
        </div>

        <div id="myList" class="c-hide">
        </div>
    </div>
</block>
<block name="js">
    <script type="text/javascript" src="__WOR__/js/api.js?v={:C('JS_CSS_VERSION')}"></script>
    <script type="text/javascript" src="__WOR__/js/recomm.api.js?v={:C('JS_CSS_VERSION')}"></script>
    <script type="text/javascript">
        var currPage = 1;
        $(function () {
            getList(currPage);
        });

        //点击搜索
        $(document).on('click', '.search-btn', function () {
            getList(currPage = 1);
        });

        //点击分页
        $(document).on('click', '.my-page li a', function () {
            var page = $(this).attr('data-page');
            if (!page) {
                return false;
            }

            var total = $('.my-page').attr('data-total');
            if (parseInt(page) > parseInt(total)) {
                page = total;
            }
            getList(currPage = page);
        });


        /**
         * 获取用户列表
         **/
        function getList(page, callback) {
            if (typeof callback != "function") {
                callback = emptyFunc;
            }
            var data = getFormData();
            page = page ? page : 1;
            data.page = page;
            doGetUserList(data, function (res) {
                if (res.Code != 10000) {
                    showErr(res.Message);
                    $('#myList').hide();
                    callback(res);
                    return false;
                }

                $('#myList').show().html(res.Result);
                hideErr();
                callback(res);
            })
        }

        /**
         * 显示页面错误页面
         * @param msg
         */
        function showErr(msg) {
            $('.c-nodata').show().find('.msg').html(msg);
        }

        /**
         * 隐藏错误页面
         */
        function hideErr() {
            $('.c-nodata').hide().find('.msg').text('');
        }
    </script>
</block>